<?php
namespace app\common\validate;

use think\Validate;

class ProductValidate extends Validate
{
    protected $rule =   [
        'page|页数'            => 'require|integer',
        'limit|条数'           => 'require|integer',
        'id'                   => 'require|number',
        'product_id|产品ID'    => 'require|integer',
        'name|产品名称'        => 'require|length:1,100',
        'show_img|展示图片'    => 'require|image',
        'cate_id|所属分类'     => 'require|gt:0',
        'sku_id|规格'          => 'require',
        'price|价格'           => 'require|gt:0',
    ];
    
    protected $scene = [
        /** api */
        'list_api'      => ['page', 'limit', 'cate_id'],
        'show'          => ['product_id'],

        /** admin */
        'list'       => ['page', 'limit'],
        'show_admin' => ['id'],
        'add'        => ['name', 'show_img', 'cate_id', 'price', 'sku_id'],
        'edit'       => ['id', 'name', 'cate_id', 'price', 'sku_id'],
    ];
}